package
{
	import jnBase.Api;
	import jnBase.Data;
	import jnBase.ShiyanControl;
	import jnBase.eventdispatcher.JNEventDispatcher;
	import jnBase.view.PPTPlayer;
	import jnBase.view.TxtDialog;
	import jnBase.view.TxtDialogWAP;
	
	import laya.display.Scene;
	import laya.ui.Dialog;
	import laya.utils.Browser;
	
	public class MyShiyan extends ShiyanControl
	{
		private static var _tiZhong:Number;
		private  var dlg_fangfa:Dialog;
		private  var dlg_mudi:Dialog;
		private  var dlg_zhuyi:Dialog;
		public function MyShiyan()
		{
			super();
			Data.stepList=[
				{des:"1.眉栏",value:["1.基本信息","2.日期","3.住院天数","4.手术后天数"]},
				{des:"2.40-42℃横线之间",value:[]},
				{des:"3.体温曲线的绘制",value:["1.原始体温","2.物理降温后体温"]},
				{des:"4.脉搏、心率曲线的绘制",value:[]},
				{des:"5.呼吸的记录",value:[]},
				{des:"6.底栏",value:["1.血压","2.尿量","3.大便次数","4.入量/出量","5.体重/身高"]},

			];
			Data.shiyanQiCai=[
				{img:'tools/box_mianqian.png',value:"mianqian",title:"棉签"},

			];
			Data.shiyanShiji=[
				{img:'tools/fengcunye.png',value:"fengcunye",title:"肝素生理盐水"},
				{img:'tools/shangqing.png',value:"shangqing",title:"上清液"},

			];
			Data.loadurlList=[
				{url:"loading/001.png",des:""},
				{url:"loading/002.png",des:""},
				{url:"loading/003.png",des:""},
				{url:"loading/005.png",des:""}
			];
			Data.assetsList=
				[
					[{type:"image",url:"comp/3d_action_02.png"},
						{type:"image",url:"comp/img_3d_action_02.png"},
						{type:"image",url:"comp/img_bg_line.png"},
						{type:"image",url:"comp/img_ms.png"},
						{type:"image",url:"comp/img_ms1.png"},
						{type:"image",url:"comp/img_notice_tip.png"},
						{type:"json",url:"fileconfig.json"},
						{type:"image",url:"loading/001.png"},
						{type:"image",url:"loading/002.png"},
						{type:"image",url:"loading/003.png"},
						{type:"image",url:"loading/005.png"},
						{type:"image",url:"loading/loading.jpg"},
						{type:"image",url:"loading/res_box.png"},
						{type:"image",url:"mobile/img_dialogMask.png"},
						{type:"image",url:"mobile/img_dialogTipBg.png"},
						{type:"image",url:"mobile/img_dialogTop.png"},
						{type:"image",url:"mobile/img_stepBg.png"},
						{type:"image",url:"mobile/img_stepBgMask.png"},
						{type:"image",url:"mobile/img_testNameBg.png"},
						{type:"image",url:"mobile/img_xiala2.png"},
						{type:"image",url:"mobile/img_yaojiBg.png"},
						{type:"json",url:"model3d/Container3D.json"},
						{type:"json",url:"model3d/RockerView.json"},
						{type:"json",url:"prefab/box_zhishi.json"},
						{type:"json",url:"prefab/Bullet.json"},
						{type:"json",url:"prefab/Buttle.json"},
						{type:"json",url:"prefab/DropBox.json"},
						{type:"atlas",url:"res/atlas/comp.atlas"},
						{type:"atlas",url:"res/atlas/loading.atlas"},
						{type:"atlas",url:"res/atlas/mobile.atlas"},
						{type:"atlas",url:"res/atlas/test.atlas"},
						{type:"atlas",url:"res/atlas/tools.atlas"},
						{type:"json",url:"runtime.json"},
						{type:"json",url:"shiyan/shiyanyuanli.json"},
						{type:"json",url:"shiyan/SYBaoGao.json"},
						{type:"json",url:"shiyan/SYJieGuo.json"},
						{type:"json",url:"shiyanjieguoIpt.json"},
						{type:"json",url:"shiyanobj.json"},
						{type:"json",url:"steps/Dia_Biaozhunxian.json"},
						{type:"json",url:"steps/step1_chengliang.json"},
						{type:"json",url:"test/TestScene.json"},
						{type:"json",url:"Text1.json"},
						{type:"json",url:"TextInput1.json"},
						{type:"json",url:"tools/capBar.json"},
						{type:"json",url:"tools/End.json"},
						{type:"json",url:"tools/Loading.json"},
						{type:"json",url:"tools/loading_normal.json"},
						{type:"json",url:"tools/MyDialog.json"},
						{type:"json",url:"tools/NormalDialog.json"},
						{type:"json",url:"tools/PaiHangBang.json"},
						{type:"json",url:"tools/PPT.json"},
						{type:"json",url:"tools/SceneTools.json"},
						{type:"json",url:"tools/step_up.json"},
						{type:"json",url:"tools/toolsDialog.json"},
						{type:"json",url:"tools/txtDialog.json"},
						{type:"json",url:"tools/UserNav.json"},
						{type:"json",url:"tools/VideoBg.json"},
						{type:"json",url:"tools/wap/OneTitle.json"},
						{type:"json",url:"tools/wap/SceneToolsWAP.json"},
						{type:"json",url:"tools/wap/toolsDialogWAP.json"},
						{type:"json",url:"tools/wap/TwoTitle.json"},
						{type:"json",url:"tools/wap/txtDialogWAP.json"},
						{type:"json",url:"unpack.json"},
						{type:"json",url:"version.json"},
						{type:"image",url:"背景.jpg"},
						{type:"image",url:"背景1.jpg"},
						{type:"image",url:"表.jpg"},
					]
				]
			
			if(Browser.onPC){
				/*实验目的*/
				dlg_mudi=new TxtDialog(500,400,Data.shiyanData[1].value,Data.shiyanData[1].name);
				/*实验方法*/
				dlg_fangfa=new TxtDialog(1320,800,Data.shiyanData[3].value,Data.shiyanData[3].name);
				/*注意事项*/
				dlg_zhuyi=new TxtDialog(600,400,Data.shiyanData[4].value,Data.shiyanData[4].name);
			}
			else if(Browser.onMobile){
				/*实验目的*/
				dlg_mudi=new TxtDialogWAP(1500,800,Data.shiyanData[1].value,Data.shiyanData[1].name);
				/*实验方法*/
				dlg_fangfa=new TxtDialogWAP(1500,800,Data.shiyanData[3].value,Data.shiyanData[3].name);
				/*注意事项*/
				dlg_zhuyi=new TxtDialogWAP(1500,800,Data.shiyanData[4].value,Data.shiyanData[4].name);
			}
			dlg_zhuyi=new TxtDialog(600,400,Data.shiyanData[4].value,Data.shiyanData[4].name);
			dlg_yuanli=ShiYanYuanli.getInstance();
			JNEventDispatcher.getInstance().on("mudi",this,showMudi);
			JNEventDispatcher.getInstance().on("zhuyishixiang",this,shiyanZhuYiShiXiang);
			JNEventDispatcher.getInstance().on("fangfa",this,shiyanFangfa);
			JNEventDispatcher.getInstance().on("yuanli",this,showYuanli);
			JNEventDispatcher.getInstance().on("baogao",this,showBaogao);
			JNEventDispatcher.getInstance().on("jieguo",this,showJieguo);
			getServerData();
		}
		/**
		 *实验目的 
		 * 
		 */		
		private function showMudi():void
		{
			// TODO Auto Generated method stub
			dlg_mudi.popup();
		}
		/**
		 *注意事项
		 */
		private function shiyanZhuYiShiXiang():void{
			dlg_zhuyi.popup();
		}
		/**
		 *实验方法 
		 * 
		 */		
		private function shiyanFangfa():void{
			dlg_fangfa.popup();
		}

		private function showJieguo():void
		{
			// TODO Auto Generated method stub
			ShiYanJieGuo.getInstance().popup();
		}
		
		private function showBaogao():void
		{
			// TODO Auto Generated method stub
			ShiYanBaoGao.getInstance().popup();
		}
		
		private function showYuanli():void
		{
			// TODO Auto Generated method stub
			dlg_yuanli.popup();
		}
		/**
		 *获取服务器上保存的数据 
		 * 
		 */		
		private function getServerData():void
		{
			// TODO Auto Generated method stub
			if(Data.token && Data.practiceInfo.tempvalue){
				var tempvalue:Object=Data.practiceInfo?JSON.parse(Data.practiceInfo.tempvalue):{};
				if(tempvalue.tizhong){
					trace('tempvalue.tizhong:',tempvalue.tizhong)
					tiZhong=tempvalue.tizhong;
				}
				else setLocaldata()
			}
			else{
				setLocaldata();
			}
		}
		
		/**
		 *首次启动程序初始化数据 
		 * 
		 */		
		private function setLocaldata():void{
			tiZhong = Math.round(Math.random()*100)+250;
		}
		/**
		 *提交实验中用到的数据，保存到服务器上，以免刷新之后数据会重置。 
		 * 
		 */		
		private static function submitShiyanData():void{
			Api.SaveTempValue(Data.operationType,Data.PracticeId,JSON.stringify(shiyanServerData))
		}
		public static function set tiZhong(value:Number):void
		{
			_tiZhong = value;
			shiyanServerData.tizhong=_tiZhong;
			Laya.timer.callLater(null,submitShiyanData);
		}
		/**兔子体重*/
		public static function get tiZhong():Number
		{
			return _tiZhong;
		}

		override protected function showPage():void
		{
			// TODO Auto Generated method stub
			switch(Data.currStep+1)
			{
				case 1:
				{
					Scene.open("steps/step1_meilan.scene"); 
					break;
				}
				case 2:
				{
					Scene.open("steps/step2_4042hengxian.scene");
					break ;
				}
				case 3:
				{
					Scene.open("steps/step3_tiwenquxian.scene");
					break ;
				}
				case 4:
				{
					Scene.open("steps/step4_MXquxian.scene");
					break ;
				}
				case 5:
				{
					Scene.open("steps/step5_huxi.scene");
					break ;
				}
				case 6:
				{
					Scene.open("steps/step6_dilan.scene");
					break ;
				}	
				default:
				{
					break;
				}
			}
			super.showPage();
		}
		private static var _ins:MyShiyan;
		private var dlg_yuanli:ShiYanYuanli;
		public static function getInstance():MyShiyan{
			if(_ins==null){
				_ins=new MyShiyan();
			}
			return _ins;
		}
	}
}